/**
 * Created by zander on 2017/12/21.
 */

function saveEmail() {
    var eamil = $("#Addemail").val();
    var sessionStorage = window.sessionStorage;
    sessionStorage.setItem('myemail', eamil);
    $('#myEmail').modal('hide');
}

function jobStatus(id, btn) {
    $.ajax({
        type: "POST",
        url: "/getjobStatus",
        data: {id: id},
        async: true,
        dataType: "json",
        success: function (ret) {
            if (ret.status == "0000") {
                $("#btnruner" + btn).removeAttr("disabled");
            }
        },

    });
}

function run1() {
    $("#btnruner1").button('loading').queue(function () {
        var sessionStorage = window.sessionStorage;
        var myemail = sessionStorage.getItem('myemail');
        var localStorage = window.localStorage;
        var name = localStorage.getItem('name');
        $.ajax({
            type: "POST",
            url: "/buildjob",
            data: {jobid: 30, email: myemail, username: name},
            dataType: "json",
            success: function (ret) {
                if (ret.status == "0000") {
                    $("#btnruner1").attr("disabled", "disabled");
                }
            },

        });
        window.sessionStorage.clear();
    });
}

function run2() {
    $("#btnruner2").button('loading').queue(function () {
        var sessionStorage = window.sessionStorage;
        var myemail = sessionStorage.getItem('myemail');
        var localStorage = window.localStorage;
        var name = localStorage.getItem('name');
        $.ajax({
            type: "POST",
            url: "/buildjob",
            data: {jobid: 31, email: myemail, username: name},
            dataType: "json",
            success: function (ret) {
                if (ret.status == "0000") {
                    $("#btnruner2").attr("disabled", "disabled");
                }
            },
        });
        window.sessionStorage.clear();
    });
}

function sessionClear() {
    window.sessionStorage.clear();
}

window.onload = sessionClear();
// window.onload = jobStatus(30,1);
// window.onload = jobStatus(31,2);